-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Global API Key (X-Auth-Key) support to Wrangler #1351
Conversation
🦋 Changeset detectedLatest commit: 42f053a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
bd2680f
to
ea12efd
Compare
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2568855771/npm-package-wrangler-1351 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/1351/npm-package-wrangler-1351 Or you can use npx https://prerelease-registry.developers.workers.dev/runs/2568855771/npm-package-wrangler-1351 dev path/to/script.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks for adding tests too! I think we should remove the GLOBAL / Global word everywhere, but I'm going to stamp it anyway. Feel free to land it after removing Global.
}); | ||
}); | ||
|
||
it("should use a Global API Key in preference to an API key", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it("should use a Global API Key in preference to an API key", async () => { | |
it("should use a Global API Key in preference to an API token", async () => { |
variableName: "CLOUDFLARE_API_TOKEN", | ||
deprecatedName: "CF_API_TOKEN", | ||
}); | ||
const getCloudflareGlobalAuthKeyFromEnv = getEnvironmentVariableFactory({ | ||
variableName: "CLOUDFLARE_GLOBAL_API_KEY", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variableName: "CLOUDFLARE_GLOBAL_API_KEY", | |
variableName: "CLOUDFLARE_API_KEY", |
we can remove this GLOBAL prefix everywhere!
deprecatedName: "CF_API_KEY", | ||
}); | ||
const getCloudflareGlobalAuthEmailFromEnv = getEnvironmentVariableFactory({ | ||
variableName: "CLOUDFLARE_GLOBAL_API_EMAIL", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variableName: "CLOUDFLARE_GLOBAL_API_EMAIL", | |
variableName: "CLOUDFLARE_EMAIL", |
return { | ||
apiToken: usingGlobalAuthKey ? apiToken.authKey : apiToken.apiToken, | ||
authType: usingGlobalAuthKey | ||
? "Global API Key" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? "Global API Key" | |
? "API Key" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a changeset!
The other vars are basically the older ones but with CF replaced with CLOUDFLARE. Since these are usually typed out at the command line, I'd prefer them them to be shorter (honestly I like CF too, but coldfusion got there before us so we have to use CLOUDFLARE instead) BUT. I don't feel strongly about this! Feel free to take a call. I'll stamp this once you add a changeset tho. |
Taking this over, will review and land. Thank you so much @geelen! |
ea12efd
to
53a8a94
Compare
Closes #1072
CLOUDFLARE_API_KEY
andCLOUDFLARE_EMAIL
or the deprecatedCF_API_KEY
andCF_EMAIL
keys.CLOUDFLARE_API_TOKEN
and oAuth.Refactored the assumption that an
apiToken
was a string and have replaced that with anApiCredentials
type:This flowed fairly easily through the code, picked up inside
addAuthorizationHeaderIfUnspecified
:I chose to preserve the semantics that if the code has injected a specific
Authorization
header, we should send it on rather than replacing it with the global Key/Email (since it's used for time-limited JWTs for Pages uploads)